# 自动下载 bootstrap-icons 1.10.5 到本地 static 目录，并自动修正字体路径
$staticPath = "D:\code\simple-logistics-card-system\LogisticsCard\static"
$cssPath = "$staticPath\css"
$fontsPath = "$staticPath\fonts"

# 创建目录
if (!(Test-Path $cssPath)) { mkdir $cssPath }
if (!(Test-Path $fontsPath)) { mkdir $fontsPath }

# 下载 CSS
Invoke-WebRequest -Uri "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" -OutFile "$cssPath\bootstrap-icons.css"

# 下载字体文件
Invoke-WebRequest -Uri "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/fonts/bootstrap-icons.woff2" -OutFile "$fontsPath\bootstrap-icons.woff2"
Invoke-WebRequest -Uri "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/fonts/bootstrap-icons.woff" -OutFile "$fontsPath\bootstrap-icons.woff"
Invoke-WebRequest -Uri "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/fonts/bootstrap-icons.ttf" -OutFile "$fontsPath\bootstrap-icons.ttf"

# 修正 bootstrap-icons.css 字体路径
(Get-Content "$cssPath\bootstrap-icons.css") -replace "/fonts/bootstrap-icons", "/static/fonts/bootstrap-icons" | Set-Content "$cssPath\bootstrap-icons.css"

Write-Host "bootstrap-icons 已下载并本地化，static/css/bootstrap-icons.css 和 static/fonts/ 已就绪。"
